package DBLayer;

import static org.junit.Assert.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import ModelLayer.*;

public class DBForestillingTest {
	private DBForestilling dbForestilling;
	@Before
	public void setUp() throws Exception {
		dbForestilling = new DBForestilling();
	}

	@After
	public void tearDown() throws Exception {
	}

	@Test
	public void testGetAllDepartment() {
		dbForestilling.getAllForestillinger(true);
		fail("Not yet implemented");
	}

	@Test
	public void testFindForestilling() {
		Forestilling fsObj = dbForestilling.getForestilling(11, true);
		if (fsObj != null) {
			System.out.println("ForestillingId     " + fsObj.getForestillingId() + "\n "
					+ "Dato       " + fsObj.getFremvisningsDato() + "\n " + "Tid        " + fsObj.getStart()+ " - " + fsObj.getSlut() + "\n " + "Film       " + fsObj.getFilm().getTitel() + "\n salNr -   " + fsObj.getSal().getSalNr());
		} else {
			fail("Forestilling not found");
		}
	}

	@Test
	public void testSearchDeparmentOnName() {
		fail("Not yet implemented");
	}

	@Test
	public void testInsert() throws Exception {
	byte t = 1;
	Film fiObject = new Film("En kongelig affaere");
	Sal saObject = new Sal(t);
	//Forestilling fObject = new Forestilling("2012/05/15", 13:10, 15:10, fiObject, saObject);
	//dbForestilling.insertForestilling(fObject);
	
	//Normally you would delte the forestilling after inserting in an insert test but because we wanted to find the betaling afterwords the delete was not implemented
}
	

	@Test
	public void testUpdate() {
		byte t = 4;
		Film fiObject = new Film("En kongelig affaere");
		Sal saObject = new Sal(t);
		
			Forestilling fsObj = dbForestilling.getForestilling(10, false);
		if (fsObj != null) {
			fsObj.setFilm(fiObject);
			fsObj.setSal(saObject);
			fsObj.setStart("18:25");
			fsObj.setSlut("21:14");
			fsObj.setFremvisningsDato("2013/09/21");	
			dbForestilling.updateForestilling(fsObj);
		} else {
			fail("Forestilling not found");
		}
	}

	@Test
	public void testDelete() {
		dbForestilling.deleteForestilling(13);
		fail("Not yet implemented");
	}

}